package com.qing.function;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

public class FactionService {

    public static  <T,R> List<R> map(List<T> list, Function<T,R> f){
        List<R> result=new ArrayList<>();
        for (T t : list) {
            result.add(f.apply(t));
        };
        return  result;
    }

    public static void main(String[] args) {
        List<Integer> map=map(Arrays.asList("hello","I love you","我爱你","你好","中文"),(String s)->s.length());
        System.out.println(map);
    }
}
